<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            box-sizing: border-box;
        }

        body {
            display: flex;
            align-items: center;
            justify-content: center;
            background-image: url(https://cdn.pixabay.com/photo/2016/06/02/02/33/triangles-1430105__480.png);
            background-repeat: no-repeat;
            background-size: contain;
            opacity: 0.8;
            height: 100vh;
            overflow: hidden;
            margin: 0;
        }

        .bigBox {
            display: flex;
            width: 90vw;
        }

        .box {
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            height: 80vh;
            border-radius: 50px;
            color: #fff;
            cursor: pointer;
            flex: 0.5;
            margin: 10px;
            position: relative;
            transition: all 700ms ease-in;
        }

        .box h3 {
            font-size: 24px;
            position: absolute;
            bottom: 20px;
            left: 20px;
            margin: 0;
            /* 不透明度 */
            opacity: 0;
        }

        .box.active {
            flex: 5;
        }

        .box.acitve h3 {
            opacity: 1;
            transition: opacity 0.3s ease-in 0.4s;
        }
    </style>
</head>
<body>
    <div class="bigBox">
        <div class="box acitve" style="background-image: url(https://cdn.pixabay.com/photo/2017/08/30/01/05/milky-way-2695569__480.jpg);">
            <h3>stars</h3>
        </div>
        <div class="box acitve" style="background-image: url(https://cdn.pixabay.com/photo/2018/08/14/13/23/ocean-3605547__480.jpg);">
            <h3>sea</h3>
        </div>
        <div class="box acitve" style="background-image: url(https://cdn.pixabay.com/photo/2018/01/14/23/12/nature-3082832__480.jpg);">
            <h3>island</h3>
        </div>
        <div class="box acitve" style="background-image: url(https://cdn.pixabay.com/photo/2016/10/20/18/35/earth-1756274__480.jpg);">
            <h3>earth</h3>
        </div>
        <div class="box acitve" style="background-image: url(https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg);">
            <h3>sunset</h3>
        </div>
    </div>

    <script>
        // 返回与指定的选择器组匹配的文档中的元素列表
        const box = document.querySelectorAll('.box')

        box.forEach(box => {
            box.addEventListener('click', () => {
                removeActiveClasses()
                box.classList.add('active')
            })
        })

        function removeActiveClasses() {
            box.forEach(box => {
                box.classList.remove('active')
            })
        }
    </script>
</body>
</html>